package structs

import (
	"context"
	"zhonghui/console/warehouse/modelx/model_zh_kernel"

	"github.com/dgrijalva/jwt-go"
)

type TokenClaims struct {
	UserID uint `json:"user_id"`
	jwt.StandardClaims
}

type PolicyConf struct {
	Effect   string   `json:"effect"`
	Action   []string `json:"action"`
	Resource string   `json:"resource"`
}

const UserCtx = "current-user"

func GetUserByCtx(c context.Context) *model_zh_kernel.ConsoleManager {
	if v := c.Value(UserCtx); v != nil {
		return v.(*model_zh_kernel.ConsoleManager)
	}
	return nil
}
